#include <stdio.h>
int main()
{
    int b1, b2, i, j, k = 0, p, c;
    printf("Game Begin\n");
    printf("Now guess your number in mind is # # # #.\n");
    for (i = 1; i < 10 && k < 4; i++)
    {
        printf("No %d ypur number may be:%d%d%d%d\n", ++count, i, i, i, i);
        printf(" How many digits have had correctly guessed :");
        scanf(" %d", &p);
        for (j = 0; j < p; j++)
            a[k + j] = i;
        k += p;
    }
    if (k < 4)
        for (j = k; j < 4; j++)
            a[j] = 0;
    i = 0;
    printf("No %d: your number may be %d%d%d%d\n", ++count, a[0], a[1], a[2], a[3]);
    print("How many are in exact positions:");
    scanf("%d", &b2);
    if (b2 == 4)
    {
        prt();
        flag = 0;
    }
    else if (b2 - b1 == -2)
    
        bhdy(j, k);
    else if (b2 - b1 == -2)
    {
        c = a[j];
        a[j] = a[k];
        a[k] = c;
    }
    else if(b1 = b2){
         c = a[j];
        a[j] = a[k];
        a[k] = c;
    }
        
}
if (flag)
    prointf("you input error !\n");
}
prt()
{
    printf("now your number must be %d%d%d%d\n", a[0], a[1], a[2], a[3]);
    printf("Game OVer\n");
}
bhdy(s, b) int s, b;
{
    int i, c = 0, d[2];
    for (i = 0; i < 4; i++)
        if (i != s && i != b)
            d[c++] = i;
    i = a[d[1]];
    a[d[1]] = a[d[0]];
    a[d[0]] = i;
    prt();
    flag = 0;
}
